import {
  createRouter,
  createWebHistory,
  createWebHashHistory,
} from "@/vue-router";
import HomeView from "../views/HomeView.vue";
import AboutView from "../views/AboutView.vue";
import MyView  from "@/views/myView.vue";

const routes = [
  {
    path: "/",
    name: "home",
    beforeEnter: (to, from, next) => {
      console.log("beforeEnter");
    },
    meta: {},
    component: HomeView,
  },
  {
    path: "/about",
    name: "about",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: AboutView,
  },
  {
    path: "/my",
    name: "my",
    component: MyView,
    children: [
      {
        path: 'a',
        name: 'mya',
        component: {render:()=><a>a页面</a>}
      },{
        path: 'b',
        name: 'myb',
        component: {render:()=><a>b页面</a>}
      }
    ]
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
